package com.geekca.d4.work1;

import java.util.Arrays;
import java.util.Random;

public class RamdomNames {
    public static void main(String[] args) {
        String[] userNames = {"Tom", "Allen", "Peter", "John", "David"};
        Random random = new Random();
        for (int i = 0; i < userNames.length; i++) {
            int index = random.nextInt(userNames.length);
            String tmp = userNames[i];
            userNames[i] = userNames[index];
            userNames[index] = tmp;
        }
        System.out.println("打乱后的名单为: " + Arrays.toString(userNames));
    }
}
